<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <style media="screen">
    .box {width:200px; height:200px; background:#CCC; border:1px solid black; transition:0.5s all ease}
    .slideUp {height:0px;}
    </style>
    <script>
    window.onload=function (){
      let oBtn=document.getElementById('btn1');
      let oDiv=document.getElementById('div1');

      oBtn.onclick=function (){
        if(Array.from(oDiv.classList).includes('slideUp')){
          oDiv.className='box';
        }else{
          oDiv.className='box slideUp';
        }
      };
    };
    </script>
  </head>
  <body>
    <input type="button" value="按钮" id="btn1">
    <div id="div1" class="box">

    </div>
  </body>
</html>
